#ifndef _AA_NEIGHBORHOOD_H
#define _AA_NEIGHBORHOOD_H

#include "../metric/xyz.h"

//#include "../bulk_storage/bulk_storage.h"
#include "../m_tree/mTree.h"

//#define CENTER_TYPE
//#define CENTER_TYPE_WEIGHT           1.0

#define NEIGHBORS         5
#define NEIGHBORS_WEIGHT        0.2

//#define FAST_NEIGHBORS  5
//#define FAST_NEIGHBORS_WEIGHT 0.2

#define MASS_CENTER
#define MASS_CENTER_WEIGHT      1.0

#define FUNCTIONAL_GROUP
#define FUNCTIONAL_GROUP_WEIGHT 1.0

//#define BB_OXYGEN
//#define BB_OXYGEN_WEIGHT        1.0

//#define FIELDS            3
//#define FIELDS_WEIGHT           (1.0/3.0)

//#define BONDS             2
//#define BONDS_WEIGHT            0.5

#define REFERENCE_FRAME_N_CA_C 
//#define REFERENCE_FRAME_CA_CB_C

typedef unsigned char type;
typedef short aa_index;

/*struct coordinates3 {
  short x;
  short y;
  short z;
  };*/



struct aa_neighborhood {
  aa_index aa_index;
  char  pdb_name[4];

#ifdef CENTER_TYPE
  type  center_type;
#endif
#ifdef NEIGHBORS
  struct xyz_short neighbors[NEIGHBORS];
  struct xyz_short neighbor_dirs[NEIGHBORS];
  type                neighbor_types[NEIGHBORS];
  aa_index               neighbor_indices[NEIGHBORS];
#endif

#ifdef FAST_NEIGHBORS
  struct short pair_mass_center_d [(NEIGHBORS * (NEIGHBORS - 1)) / 2];
  //  struct short pair_functional_group_d [(NEIGHBORS * (NEIGHBORS - 1)) / 2];
#endif

#ifdef MASS_CENTER
  struct xyz_short mass_center;
#endif
#ifdef FUNCTIONAL_GROUP
  struct xyz_short functional_group;
#endif
#ifdef BB_OXYGEN
  struct xyz_short bb_oxygen;
#endif
#ifdef FIELDS
  struct xyz_short fields[FIELDS];
  type                field_types[FIELDS];
  aa_index               field_indices[FIELDS];
#endif
#ifdef BONDS
  struct xyz_short bonds[BONDS];
  type                bond_types[BONDS];
  aa_index               bond_indices[BONDS];
#endif
};


double aa_neigh_dist(const struct aa_neighborhood* n1, const struct aa_neighborhood* n2);
void aa_neigh_init(struct aa_neighborhood * neigh, const char pdbName[4], const struct store * s, struct mTree * atom_tree, off_t position);
int aa_neigh_can_calc_neighborhood(struct store * s, off_t i);


#endif // _AA_NEIGHBORHOOD_H
